package com.fucius.study.lintcode;

public class AMulB {

    public static void main(String[] args) {
        mul(-123,-234);
        mul(012,-123);
        mul(1,12);
        mul(-1,12);
        mul(0,1);
    }

    public static void mul(int a, int b) {
        //调换位置
        if (a > b) {
            int z = a;
            a = b;
            b = z;
        }
        int i = 0;
        int result = 0;
        while (b!=0) {
            if ((b&1)==1) {
                result += a<<i;
            }
            i++;
            b=b>>>1;
        }
        System.out.println(result);
    }
}
